function autoLogin() {
    var data = new FormData(document.getElementById("login_form"));
    data.set("password", hex_md5(data.get("password")));
    var loginType = $("#login-type").val();
    login(data, loginType);
    return false;
}
function login(formData, loginType) {
    $.ajax({
        url: '/' + loginType + '/login/check',
        type: 'POST',
        contentType: false, // 注意这里应设为false
        data: formData,
        processData: false,
        success: function (result) {
            try {
                var resultJson = JSON.parse(result);
                var isSuccess = resultJson["success"];
                var resultError = resultJson["error"];
                if (isSuccess) {
                    var privilege = resultJson["privilege"];
                    if (privilege === "普通用户") {
                        window.location.href = "/";
                    } else if (privilege === "超级管理员") {
                        window.location.href = "/admin/index";
                    } else {
                        alert("登录成功,但是权限出现异常");
                    }
                } else {
                    if (resultError == null) {
                        alert("登录失败!");
                    } else {
                        alert(resultError);
                    }
                }
            } catch (e) {
                alert("登录异常");
            }
        }
    });
}